﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using ZebraCoreLib.Framework;
using System.Reflection;

namespace Web.ZebraUIControls
{
    public abstract class ZebraInputControl:ZebraBasControls
    {

        public string DataField { get; set; } 
        private ZebraFieldAttribute fieldAttr = null;
        public string Value { get; set; }
        protected ZebraFieldAttribute FieldAttribute
        { 
            get
            {
                if (fieldAttr == null)
                {
                    try
                    {
                        PropertyInfo property = BizObjectType.GetProperty(DataField, BindingFlags.IgnoreCase| BindingFlags.Public | BindingFlags.Instance );
                        fieldAttr= BizServiceHelper.GetZebraFieldAttribute(property);
                        //var attributes = property.GetCustomAttributes(typeof(ZebraFieldAttribute), false);
                        //if (attributes != null && attributes.Length >= 0)
                        //    fieldAttr = attributes[0] as ZebraFieldAttribute;
                    }
                    catch { ;}
                }
                return fieldAttr;
            }
        }
        public override void RenderControl(HtmlTextWriter writer)
        {

            base.RenderControlFromTemplate(writer, FieldAttribute);
        }
    }
}
